package graphics.raytracing;
import static util.MatrixOperationsF.*;

import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Collection;

import drawing.DrawingEngine;

import graphics.rasterizing.camera.CameraPosition;
import graphics.rasterizing.model.Triangle;
import io.rasterizing.SimpleReader;
public class Raytracermain {
	private static int xmax=200;
	private static int ymax=200;

	//XXX:remove this class
	public static void main(String[] args) throws Exception {
		DrawingEngine engine = new DrawingEngine(xmax, ymax);
		engine.go();
		LightSource source = new DirectionalLigtSource(ar(-1,-1,-1,1));
		Window window = new Window(ar(-3,-1,-4,1), ar(6,0,-4,1), ar(0,4,-4,1), xmax,ymax, source);
		io.raytracing.SimpleReader reader = new io.raytracing.SimpleReader("c:/cgobjects/teapot.obj");
		Model model =reader.read();//new SimpleTriangleMesh();
		CameraPosition pos = new CameraPosition(ar(0,0,-80,1),ar(0,0,-1,1),ar(1,1,1,1));
		RayTracer tracer = new RayTracer(model, window, pos);
		int[][] wind =tracer.traceRays();
		System.out.println("no exceptions woooohoooooo");
		engine.draw(wind);
	}
	private static Collection<Triangle> genTriangles() {
		ArrayList<Triangle> rv = new ArrayList<Triangle>();
		float[][] points = new float[3][4];
		float[][] colors = new float[3][3];
		points[0] = ar(0, 8, 0, 1);
		points[1] = ar(4, 0, 10, 1);
		points[2] = ar(8, 8, 0, 1);
		colors[0] = ar(0, 0, 1);
		colors[1] = ar(0, 0, 1);
		colors[2] = ar(0, 0, 1);
		rv.add(new Triangle(points, colors));
		points = new float[3][4];
		colors = new float[3][3];
		points[0] = ar(8, 0, 0, 1);
		points[1] = ar(4, 4, 10, 1);
		points[2] = ar(0, 0, 0, 1);
		colors[0] = ar(0, 1, 0);
		colors[1] = ar(0, 1, 0);
		colors[2] = ar(0, 1, 0);
		rv.add(new Triangle(points, colors));
		// points = new float[3][4];
		// colors = new float[3][3];
		// points[0] = ar(6,3,2,1);
		// points[1] = ar(6,2,2,1);
		// points[2] = ar(1,3,0,1);
		// colors[0] = ar(1,0,0);
		// colors[1] = ar(1,0,0);
		// colors[2] = ar(1,0,0);
		// rv.add(new Triangle(points, colors));
		return rv;
	}
}
